﻿using System.Collections.Generic;
using Loki.Engine;
using Luna.Connectors;
using Luna.Data;
using Luna.Data.Budget;
using Luna.Data.Configuration;
using Luna.Data.CRM;
using Luna.Data.SqlServer;

namespace Luna.UI.Wpf
{
    public class DataContext : ObjectModel, IDataContext
    {
        protected override void InternalLoad()
        {
            base.InternalLoad();

            DatabaseInstaller.SqlServer.Install(InternalContext);

            Luna.Connectors.Google.ConnectorInstaller.Google.Install(InternalContext);
            Luna.Connectors.ZohoCRM.ConnectorInstaller.Zoho.Install(InternalContext);

            DataInstallers.All.Install(InternalContext);

            _Connectors = ConnectorLoader();
        }

        private IDictionary<ConnectorType, IConnector> _Connectors;

        public IDictionary<ConnectorType, IConnector> Connectors
        {
            get
            {
                return _Connectors;
            }
        }

        private IDictionary<ConnectorType, IConnector> ConnectorLoader()
        {
            var L_Return = new Dictionary<ConnectorType, IConnector>();

            /*L_Return[ConnectorType.Google] = InternalContext.Resolve<IConnector>(ConnectorType.Google.ToString());
            L_Return[ConnectorType.ZohoCRM] = InternalContext.Resolve<IConnector>(ConnectorType.ZohoCRM.ToString());*/

            return L_Return;
        }

        public IBudgetProvider Budget
        {
            get { return InternalContext.Resolve<IBudgetProvider>(); }
        }

        public IContactProvider Contacts
        {
            get { return InternalContext.Resolve<IContactProvider>(); }
        }

        public IConfigurationProvider Configuration
        {
            get { return InternalContext.Resolve<IConfigurationProvider>(); }
        }
    }
}